# -*- coding: utf-8 -*-
# File : secet_free.py
# Author: taoyahui
# Date : 2021/6/16
import os
import results


# 分发密钥给指定IP(需要用户名和密码)
def key_distribute(ip, user, password):
    val = os.system(f'sshpass -p {password} ssh-copy-id {user}@{ip} -o StrictHostKeyChecking=no &> /dev/null')
    if val != 0:
        return results.sshpass_error_result
    else :
        return results.success_result


if __name__ == '__main__':
    print(key_distribute('192.168.50.199', 'root', '123456'))